﻿using Coldairarrow.Business.PB;
using Coldairarrow.Entity.DTO;
using Coldairarrow.Entity.PB;
using Coldairarrow.Util;
using Microsoft.AspNetCore.Mvc;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Coldairarrow.Api.Controllers.PB
{
    [Route("/PB/[controller]/[action]")]
    public class PB_ProcecureSubController : BaseApiController
    {
        #region DI

        public PB_ProcecureSubController(IPB_ProcecureSubBusiness pB_ProcecureSubBus)
        {
            _pB_ProcecureSubBus = pB_ProcecureSubBus;
        }

        IPB_ProcecureSubBusiness _pB_ProcecureSubBus { get; }

        #endregion

        #region 获取

        [HttpPost]
        public async Task<PageResult<PB_ProcecureSub>> GetDataList(PageInput<ConditionDTO> input)
        {
            return await _pB_ProcecureSubBus.GetDataListAsync(input);
        }

        [HttpPost]
        public async Task<PB_ProcecureSub> GetTheData(IdInputDTO input)
        {
            return await _pB_ProcecureSubBus.GetTheDataAsync(input.id);
        }
        [HttpPost]
        public async Task<List<PB_ProcecureListDto>> GetDataListByDepartment(string DeptId)
        {
            return await _pB_ProcecureSubBus.GetDataListByDepartment(DeptId);
        }

       /// <summary>
       /// 根据工艺id查询工序并附带查询
       /// </summary>
       /// <param name="input"></param>
       /// <param name="parentid"></param>
       /// <returns></returns>
        [HttpPost]
        public  async Task<PageResult<PB_ProcecureSubDTO>> GetDataListAsyncsok(PageInput<ConditionDTO> input, string parentid) {
            return await _pB_ProcecureSubBus.GetDataListAsyncsok(input,parentid);
        }
        [HttpPost]
        public async Task<List<PB_ProcecureSubDTO>> GetDataLists(string parentid)
        {
            var res = await _pB_ProcecureSubBus.GetDataListAsyncs(parentid);
            return res;
        }

        [HttpPost]
        public async Task<List<ProcecureSubTreeDTO>> GetTreeSubListAsyncs()
        {
            return await _pB_ProcecureSubBus.GetTreeSubListAsyncs();
        }
        [HttpPost]
        ///获取今天报工的工序
        public async Task<List<RapidqualitySubDays>> GetRapidqualitySubDaysList() {
            var list = await _pB_ProcecureSubBus.GetRapidqualitySubDaysList();
            return list;
        }
        [HttpPost]
        public async Task<PageResult<WorkReportWorklist>> GetWorkReportWorklist(PageInput<WorkReportWorkSearch> input) { 
            var list = await _pB_ProcecureSubBus.GetWorkReportWorklist(input);
            return list;
        }
        /// <summary>
        /// 获取报工历史
        /// </summary>
        /// <param name="SubId"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<PageResult<WorkReportWorklist>> GetWorkReportHistory(PageInput<WorkReportWorkSearch> input) { 
            var list = await _pB_ProcecureSubBus.GetWorkReportWorklist(input);
            return list;
        }
        /// <summary>
        /// PDA批量质检统计操作
        /// </summary>
        /// <param name="Data"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task BatchSave_Statistics(BatchSave_Statistics Data) {
             await _pB_ProcecureSubBus.BatchSave_Statistics(Data);
        }
        #endregion

        #region 提交

        [HttpPost]
        public async Task SaveData(PB_ProcecureSub data)
        {
            if (data.Id.IsNullOrEmpty())
            {
                InitEntity(data);

                await _pB_ProcecureSubBus.AddDataAsync(data);
            }
            else
            {
                await _pB_ProcecureSubBus.UpdateDataAsync(data);
            }
        }

        [HttpPost]
        public async Task DeleteData(List<string> ids)
        {
            await _pB_ProcecureSubBus.DeleteDataAsync(ids);
        }

        [HttpPost]
        public async Task<List<PB_ProcecureSub>> GeFinishe() {
            var res = await _pB_ProcecureSubBus.GeFinishe();
            return res;
        }


        [HttpPost]
        public async Task<PageResult<ProceduredaySummary>> GetProceduredaySummary(PageInput<IT_LocalDetailDtolistContionDTO> input) {
            return await _pB_ProcecureSubBus.GetProceduredaySummary(input);
        }

        [HttpPost]
        public async Task<PageResult<SprayList>> GetSprayList(PageInput<IT_LocalDetailDtolistContionDTO> input) {
            return await _pB_ProcecureSubBus.GetSprayList(input);
        }
        #endregion
    }
}